NAME			?= led
TARGET 			?= $(NAME)bin
CROSS_COMPILE	?= arm-linux-gnueabihf-
OBJS			:= start.o main.o
LD 				:= $(CROSS_COMPILE)ld
OBJCOPY 		:= $(CROSS_COMPILE)objcopy
OBJDUMP 		:= $(CROSS_COMPILE)objdump
CC 				:= $(CROSS_COMPILE)gcc

$(TARGET):$(OBJS)
	$(LD) -Timx6ul.lds -o $(NAME).elf $^
	$(OBJCOPY) -O binary -S $(NAME).elf $@
	$(OBJDUMP) -D -m arm $(NAME).elf > $(NAME).dis

%.o:%.s
	$(CC) -Wall -nostdlib -c -o $@ $<

%.o:%.S
	$(CC) -Wall -nostdlib -c -o $@ $<

%.o:%.c
	$(CC) -Wall -nostdlib -c -o $@ $<

.PHONY:clean
clean:
	-rm -rf *.o $(TARGET) *.elf *.dis
